<?php
function int_ceil($value){
	return intval($value*100)/100;
}


function profit($data,$price){
    $k = 0;
    $amount=0;
	foreach ($data as $key=>$value){
		if($value->type_id != 16){
		    $amount += int_ceil($value->percentage/100*$price);
		    $data[$key]->amount = int_ceil($value->percentage/100*$price);
		}else {
		    $k = $key;
		}
	}
	$data[$k]->amount = $price - $amount;
	return $data;
}